package com.leoandroid.tool.toolsbox.largeread.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.constraintlayout.widget.ConstraintLayout;

import com.leoandroid.tool.toolsbox.largeread.R;

public class ScreenLightActivity extends BaseActivity{

    private ConstraintLayout layoutScreenLamp;
    private LinearLayout layoutClose;
    private TextView tvScreenLamp;
    private ImageView imgScreenLamp;

    private boolean isScreenLight = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_screen_light);
        initView();
    }

    private void initView(){
        layoutScreenLamp = findViewById(R.id.screen_lamp_layout);
        tvScreenLamp = findViewById(R.id.screen_lamp_tv);
        imgScreenLamp = findViewById(R.id.screen_lamp_img);
        layoutClose = findViewById(R.id.layout_close);

        layoutClose.setOnClickListener(view -> {
            finish();
        });

        tvScreenLamp.setOnClickListener(view -> {
            imgScreenLamp.setVisibility(View.VISIBLE);
            layoutClose.setVisibility(View.VISIBLE);
            tvScreenLamp.setVisibility(View.GONE);
            isScreenLight = true;
        });

        imgScreenLamp.setOnClickListener(view -> {
            if (isScreenLight) {
                imgScreenLamp.setVisibility(View.VISIBLE);
                layoutClose.setVisibility(View.VISIBLE);
                tvScreenLamp.setVisibility(View.GONE);
                layoutScreenLamp.setBackgroundColor(getResources().getColor(R.color.color_000000));
                isScreenLight = false;
            }else{
                imgScreenLamp.setVisibility(View.GONE);
                layoutClose.setVisibility(View.GONE);
                tvScreenLamp.setVisibility(View.VISIBLE);
                layoutScreenLamp.setBackgroundColor(getResources().getColor(R.color.white));
            }
        });
    }
}
